﻿@model List<CashOrCard.Models.Promotion>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
@{
    string pName = "";
    string advtId = "";
    if(ViewBag.promotion != null)
    {
        CashOrCard.Models.Promotion pm = ViewBag.promotion;
        pName = pm.PromotionName;
        advtId = pm.AdvtSite.AdvtSiteId.ToString();
    }
 }
<html>
    <head>
        <script type="text/javascript">
            function removePC() {
                var row = $('#dg').datagrid('getSelected');
                if (row) {
                    $.messager.confirm('Confirm', 'Are you sure you want to remove this promotion comment?', function (r) {
                        if (r) {
                            $.post('/PromotionComment/DeletePC', { id: row.PromotionCommentId }, function (result) {
                                if (result == "success") {
                                    $.messager.alert("Message", "Delete Successfully");
                                    $('#dg').datagrid('reload');
                                } else {
                                    $.messager.show({    // show error message
                                        title: 'Error',
                                        msg: 'Please contact the admin for support'
                                    });
                                }
                            }, 'text');
                        }
                    });
                }
                else {
                    $.messager.alert("Message", "Please select one record.");
                }
            }
        </script>
    </head>
    <body>
        <table id="dg" title="Promotion Comment" class="easyui-datagrid" style="height:500px"
                url="/PromotionComment/GetAllComments/?promotionId=@TempData["promotionId"]"
                toolbar="#toolbar" pagination="true" iconCls="icon-ok"
                rownumbers="true" fitColumns="true" singleSelect="true">
            <thead>
                <tr>
                    <th field="PromotionCommentId" width="50" hidden="true">PromotionCommentId</th>
                    <th field="PromotionCommentBody" width="50">PromotionCommentBody</th>
                    <th field="CreateDate" width="50" formatter="ToJavaScriptDate">CreateDate</th>
                    <th field="CommentUser" width="50">Comment User</th>
                </tr>
            </thead>
        </table>
        <div id="toolbar">
        <a href="/PromotionAdmin/Index/?advtId=@advtId" class="easyui-linkbutton" iconcls="icon-back" plain="true">Return to Promotion</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="removePC()">Remove Promotion Comment</a>
        &nbsp;&nbsp;&nbsp;<span style="font-weight:bold">
        Promotion Name: @pName
            </span>
    </div>
    </body>
</html>
